package com.purchasing.system.service;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.web.multipart.MultipartFile;

import com.purchasing.system.model.PurchaseRequest;
import com.purchasing.system.payload.request.PurchaseRequestDto;

import java.time.LocalDateTime;

public interface PurchaseRequestService {
    PurchaseRequest createPurchaseRequest(PurchaseRequestDto purchaseRequestDto, MultipartFile attachment, Long userId);
    
    Page<PurchaseRequest> getPurchaseRequestsByUser(Long userId, Pageable pageable);
    
    Page<PurchaseRequest> getPurchaseRequestsByUserAndStatus(Long userId, PurchaseRequest.PurchaseStatus status, Pageable pageable);
    
    Page<PurchaseRequest> getPurchaseRequestsByUserAndDateRange(Long userId, LocalDateTime startDate, LocalDateTime endDate, Pageable pageable);
    
    Page<PurchaseRequest> getPurchaseRequestsByUserAndStatusAndDateRange(Long userId, PurchaseRequest.PurchaseStatus status, LocalDateTime startDate, LocalDateTime endDate, Pageable pageable);
    
    Page<PurchaseRequest> searchUserPurchaseRequestsByItemName(Long userId, String itemName, String status, LocalDateTime startDate, LocalDateTime endDate, Pageable pageable);
    
    Page<PurchaseRequest> getPendingPurchaseRequests(Pageable pageable);
    
    Page<PurchaseRequest> getPendingPurchaseRequestsByItemName(String itemName, Pageable pageable);
    
    Page<PurchaseRequest> getPendingPurchaseRequestsByRequesterName(String requesterName, Pageable pageable);
    
    Page<PurchaseRequest> getPurchaseRequestsByStatus(PurchaseRequest.PurchaseStatus status, Pageable pageable);
    
    Page<PurchaseRequest> getAllPurchaseRequests(Pageable pageable);
    
    Page<PurchaseRequest> searchPurchaseRequests(String keyword, Pageable pageable);
    
    Page<PurchaseRequest> searchPurchaseRequestsByItemName(String itemName, Pageable pageable);
    
    Page<PurchaseRequest> searchPurchaseRequestsByRequesterName(String requesterName, Pageable pageable);
    
    Page<PurchaseRequest> getApprovedPurchaseRequests(Pageable pageable);
    
    PurchaseRequest getPurchaseRequestById(Long id, Long userId);
    
    PurchaseRequest updatePurchaseRequest(Long id, PurchaseRequestDto purchaseRequestDto, Long userId);
    
    PurchaseRequest updatePurchaseRequest(Long id, PurchaseRequestDto purchaseRequestDto, MultipartFile attachment, Long userId);
    
    void deletePurchaseRequest(Long id, Long userId);
    
    PurchaseRequest approvePurchaseRequest(Long id, boolean approved, String comment, Long approverId);
    
    Page<PurchaseRequest> findAll(Specification<PurchaseRequest> spec, Pageable pageable);
} 